<template>
  <div class="goodsDetail">
    <div>
      <div class="mt20">
        <span class="main_active">{{ translate('射频码') }}：</span>
        <div class="w400 inline-block">
          <el-tag
            v-for="tag in formInfo"
            :key="tag.ID"
            class="mx-1"
            closable
            @close="closeFn(tag)"
          >
            {{ tag.ESLCode }}
          </el-tag>
        </div>
      </div>
      <div class="mt20">
        <span class="main_active">{{ translate('图片') }}：</span>
        <div class="w400 inline-block">
          <ImgUpload
            :accept="'image/jpg, image/jpeg,image/png,image/bmp'"
            action="/CSLogoImage/CSLogoUpload?code=eslimg"
            :image-url="imgstring"
            @success="uploadSuccess"
          />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import ImgUpload from '@/views/components/imgUpload/index.vue'
  import { translate } from '@/i18n'
  export default {
    name: 'Detail',
    components: { ImgUpload },
    props: {
      form: {
        type: Array,
        default: () => {
          return []
        },
      },
    },
    emits: ['uploadsuccess', 'closetagfn'],
    data() {
      return {
        formInfo: this.form,
        imgstring: '',
        translate: translate,
      }
    },
    watch: {
      form(val) {
        this.formInfo = val
      },
    },
    methods: {
      closeFn(tag) {
        this.formInfo.splice(this.formInfo.indexOf(tag), 1)
        this.$emit('closetagfn', this.formInfo)
        console.log(this.formInfo)
      },
      uploadSuccess(data) {
        this.imgstring = data
        this.$emit('uploadsuccess', data)
      },
    },
  }
</script>
<style lang="scss" scoped>
  .goodsDetail {
    height: 300px;
  }
  .flex_align {
    display: flex;
    align-items: center;
  }
  .tableDetail {
    padding: 10px;
    .button-add {
      text-align: end;
      padding: 10px;
    }
  }
  .main_active {
    display: inline-block;
    width: 120px;
    text-align: right;
  }
  .mr20 {
    margin-right: 20px;
  }

  .w400 {
    width: 400px !important;
  }
  .mt20 {
    margin-top: 10px;
  }
  .mr10 {
    margin-right: 10px;
  }
  .w320 {
    width: 320px;
  }
  .inline-block {
    display: inline-block;
  }
  ::v-deep .el-scrollbar__wrap {
    overflow-x: auto;
    height: calc(100% + 20px); //多出来的20px是横向滚动条默认的样式
  }
  ::v-deep .el-scrollbar .el-scrollbar__wrap .el-scrollbar__view {
    white-space: nowrap;
    display: inline-block;
  }
  ::v-deep .el-table--scrollable-x .el-table__body-wrapper {
    overflow-x: hidden;
  }
  ::v-deep input[type='number']::-webkit-inner-spin-button,
  ::v-deep input[type='number']::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
  }
  ::v-deep .el-tag {
    margin-bottom: 5px;
  }
</style>
